// JavaScript Document

forms = jQuery.noConflict();
forms().ready(function() {
	forms("#addnewform-node-form").validate({
		
										/* onfocusout: false,
  										 onkeyup: false,
  										 onclick: false,*/
										 //debug:true,
										 
					rules: {
						'field_form_dept[und]': { 
							required: true,
							maxlength: 255,
							chkbadchar:true,
							valuenotequals: '_none',
						},
						'field_form_organization[und]': { 
							required: true,
							maxlength: 255,
							chkbadchar:true,
							valuenotequals: '_none',
						},
						'field_form_dist[und][]':{
							//required: true,
							//maxlength: 255,
							//chkbadchar:true,
							multi_dist_select: true,
							
							},
						'title': { 
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
						'field_form_ifany[und][0][value]':{
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,							
							},
						'field_form_classi[und]':{
							required: true,
							maxlength: 200,
							chkbadchar:true,
							},
						'field_form_category[und]':{
							valuenotequals: '_none',
						},
						'field_form_othercategory[und][0][value]':{
							//required : 'option:selected[value="5"]',
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
						'field_form_desc[und][0][value]':{
							required: true,
							minlength: 5,
							maxlength: 500,
							chkbadchar:true,
							splchar:true,							
							},
						'field_form_assoc[und]':{
							required: true,
							maxlength: 200,
							chkbadchar:true,
							},
						'field_form_services[und]':{
							valuenotequals: '_none',
						},
						'field_form_schemes[und]':{
							valuenotequals: '_none',
						},
						'field_form_othertype[und][0][value]':{
							required:'#edit-field-form-assoc-und-others',
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},							
						
						'field_annavail[und]': { 
							required: true,
							maxlength: 200,
							chkbadchar:true,
						},
						
						'field_form_avail[und][0][value]':{
							required: "#edit-field-form-type-und-online:checked",
							url: true,
							chkbadchar:true,
						},
						'files[field_form_upload_und_0]':{
							required: "#edit-field-form-type-und-download:checked",
							chkfile_format_size: true,
						},
						'field_form_keywords[und][0][value]':{
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,							
						},
						
						
						
					
					},
                    messages: {
						'field_form_dept[und]':{
							required: 'Please Select Concerned Department',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar: 'insert, select, update, delete, drop, alter, change, modify not allowed.',
							valuenotequals: 'Please Select Concerned Department',
							},
							'field_form_organization[und]':{
							required: 'Please Select Organization',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar: 'insert, select, update, delete, drop, alter, change, modify not allowed.',	
							valuenotequals: 'Please Select Organisation Name',
							},
							'field_form_dist[und][]':{
							required: 'Please Select Districts',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',	
							multi_dist_select: 'Please Select either All or Particular Districts',
							},
							'title': { 
							required:  'Please enter Title',
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',
							},
							'field_form_ifany[und][0][value]':{
							required:  'Field Value is Required',
							minlength: 'Minimum 5 characters should be entered',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',						
							},
							'field_form_classi[und]': { 
							required: 'Please select Forms Classification',
							maxlength:  'Invalid option',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							},
							'field_form_category[und]':{
								valuenotequals: 'Please Select the Category',
							},
							'field_form_othercategory[und][0][value]':{
							required:  'Please enter Other Category',
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',
							},
							'field_form_desc[und][0][value]':{
							required:'Please enter Description',
							minlength:'Minimum 5characters are allowed',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',					
							},
							'field_form_assoc[und]':{
							required: 'Please select Forms Classification',
							maxlength:  'Invalid option',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							},
							'field_form_services[und]':{
								valuenotequals: 'Please Select list of services',
							},
							'field_form_schemes[und]':{
								valuenotequals: 'Please Select list of schemes',
							},
							'field_form_othertype[und][0][value]':{
								required:  'Please enter Other Asoociated Service/Scheme',
								minlength: 'Minimum 5 characters should be entered',
								maxlength: 'Maximum 255 character only allowed',
								chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
								splchar:'Special Characters are not allowed',
							},
							
							
							'field_form_type[und]': { 
							required: 'Please select Form Type',
							maxlength:  'Invalid option',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							},
							'field_form_avail[und][0][value]':{
							required: "Please Enter URL",
							url: 'Not Valid URL',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',

							},
							'files[field_form_upload_und_0]':{
							required: 'Please select upload file',
							chkfile_format_size: 'Invalid File Format',
							},
							'field_form_keywords[und][0][value]':{
							required : 'Please Enter Keywords',
							minlength: 'Minimum 5 characters should be entered',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',					
							},
	
				}, 
					//errorLabelContainer: "#errormsg_container",
					 //focusInvalid: false,
   					invalidHandler: function(form, validator) {
       
       					 if (!validator.numberOfInvalids())
								return;
						else{
							
							  //forms("#announcements-node-form").create_errormsg_container('errormsg_container','announcements-node-form');
						}
							
							forms('html, body').animate({
								scrollTop: forms(validator.errorList[0].element).offset().top - 100
							}, 1000);
							
						},
										   
	});
});


